<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="com.shsh.safemanage.model.PostcheckStandard"%>
<%@page import="com.shsh.safemanage.model.PostcheckContent"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.PostCheckDao"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%@ page language="java" pageEncoding="UTF-8"%>

<%
{
	
PostCheckDao postcheckDao = DaoCreator.createPostCheckDao();


Long thePostcheckContentID = 0L;
String postcheckContentIDStr = (String)request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_CONTENT_ID);
try{
	thePostcheckContentID = Long.parseLong(postcheckContentIDStr);
}catch(Exception e){
	
}

PostcheckContent postcheckContent = postcheckDao.getPostcheckContentByID(thePostcheckContentID);
String content = "";
if(postcheckContent!=null){
	content = postcheckContent.getContent();
}
List<PostcheckStandard> standardList = postcheckDao.getPostcheckStandardByPostcheckContentID(thePostcheckContentID);
List<List<PostcheckStandard>> tmpList = new ArrayList<List<PostcheckStandard>>();

String source = null;
int j = 0;
for(int i = 0; i < standardList.size(); i++){
	PostcheckStandard standard = standardList.get(i);
	String sourceIds = Util.toString(standard.getSources(), ",", "");
	if(!sourceIds.equals(source)){		
		List<PostcheckStandard> tmpList2 = new ArrayList<PostcheckStandard>();
		tmpList2.add(standard);
		
		tmpList.add(tmpList2);
		source = sourceIds;
		j++;
	} else {
		List<PostcheckStandard> tmpList2 = tmpList.get(j-1);
		tmpList2.add(standard);
	}
}

%>
<table align="center" border="2" width="99%" cellpadding="0" cellspacing="1" style="table-layout: fixed;margin-bottom:5px;">
	<tr>
		<td width="75px" style="text-align:center;">
			<b>工作内容</b>
		</td>
		<td style="text-align:center;">
			<b>工作标准与要求</b>
		</td>
		<td width="155px" style="text-align:center;">
			<b>工作标准来源</b>
		</td>
		<td width="55px" style="text-align:center;">
			<b>扣分标准</b>
		</td>
		<td width="55px" style="text-align:center;">
			<b>检查频次</b>
		</td>
		<td width="60px" style="text-align:center;">
			<b>操作</b>
		</td>
	</tr>
<%
boolean contentDisplayed = false;
for (int k=0;k < tmpList.size(); k++) {
	List<PostcheckStandard> tmpList2 = tmpList.get(k);
	boolean sourceDisplayed = false;
	for (int i=0;i<tmpList2.size();i++){
		PostcheckStandard standard = tmpList2.get(i);
%>
	<tr>
		<%
		if(!contentDisplayed){
		%>
		<td rowspan="<%=standardList.size()%>" style="padding-left:3px;">
			<%=content %>
		</td>
		<%
			contentDisplayed = true;
		} %>
		<td style="text-align:left;padding-left:3px;">
		<%=standard.getStandard() %>
		</td>
		<%if (!sourceDisplayed) {%>
		<td rowspan="<%=tmpList2.size()%>" style="text-align:center;">
		<%=Util.toString(standard.getSourceNames(), "<br/>", "") %>
		</td>
		<%
			sourceDisplayed = true;
		}
		%>
		<td style="padding-left:3px;">
		<%=standard.getGradeStandard() %>
		</td>
		<td style="padding-left:3px;">
		<%=standard.getCheckFrequency() %>
		</td>
		<td style="padding-left:3px;">
			<a href="javascript:gotoUpdatePostcheckStandard(<%=standard.getId() %>)">修改</a>&nbsp;&nbsp;<a href="javascript:deletePostcheckStandard(<%=standard.getId() %>)">删除</a>
		</td>
	</tr>
<%
	}
}
%>
</table>
<%
}
%>